package com.example.ruomi.utils.result;

public class ResultUtil {
    /**成功且带数据**/
    public static Result<Object> success(Object object){
        Result<Object> result = new Result<>();
        result.setCode(ResultEnum.SUCCESS.getCode());
        result.setMsg(ResultEnum.SUCCESS.getMsg());
        result.setData(object);
        return result;
    }

    /**成功但不带数据**/
    public static Result<Object> success(){
        return success(null);
    }

    /**失败**/
    public static Result<Object> error(Integer code,String msg){
        Result<Object> result = new Result<>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    /** 自定义响应结果**/
    public static Result<Object> custom(Integer code,String msg,Object object){
        Result<Object> result = new Result<>();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(object);
        return result;
    }
}
